<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024/12/4
  Time: 14:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--html css js jquery bootstarp--%>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"/>
<script type="text/javascript">
    function register(){
        //alert(123)
        let username=document.getElementById("username").value;
        let password=document.getElementById("password").value;
        // json data
        let jsonData={"username":username,"password":password};
        //convert to json obj
        let jsonObj=JSON.stringify(jsonData);

        $.ajax({
            type:'post',
            contentType:'application/json;charset=utf-8',
            date: jsonObj,
            url:'${pageContext.request.contextPath}/stu/insert.do',
            success:respData => {
                //todo
                alert(respData.username+":"+respData.password)
            },
        })
    }
</script>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--<form action="${pageContext.request.contextPath}/stu/addStu2.do">--%>
    用户名：<input type="text" name="username" id="username"> <br>
    密码：<input type="text" name="password" id="password"> <br>
    <input type="button" value="注册" onclick="register()">
    <%--用户名：<input type="text" name="infos['username]"> <br>
    密码：<input type="text" name="infos['password']"> <br>--%>

    <%--&lt;%&ndash;用户名：<input type="text" name="studentList[1].username"> <br>
    密码：<input type="text" name="studentList[1].password"> <br>&ndash;%&gt;
    <input type="submit" value="注册">--%>
<%--</form>--%>
</body>
</html>
